package sample.note;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class ChatRegisterActivity extends AppCompatActivity
        implements View.OnClickListener{


    private Button btn;
    private EditText nickname;
    public static final String NICKNAME = "usernickname";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat_register);
        //call UI component  by id
        btn = (Button) findViewById(R.id.enterchat) ;
        nickname = (EditText) findViewById(R.id.nickname);

        btn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        //if the nickname is not empty go to chatbox activity and add the nickname to the intent extra
        if(!nickname.getText().toString().isEmpty()){
            Intent i  = new Intent(this,ChatBoxActivity.class);
            //retreive nickname from textview and add it to intent extra
            i.putExtra(NICKNAME,nickname.getText().toString());

            startActivity(i);
        }
    }
}
